package com.service;

import com.entity.RestfulResult;
import com.entity.ServiceInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**重要，如果用Controller会404**/
@RestController
@RequestMapping(value = "service")
public class ServiceController {
 
    @RequestMapping(value = "hello")
    public String login(HttpServletRequest request, HttpServletResponse response,
                      @RequestBody ServiceInfo serviceInfo) {
 
        RestfulResult restfulResult = new RestfulResult();
 
        try {
            restfulResult.setData("Service1:Welcome " + serviceInfo.getName() + "!");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  restfulResult.toString();
    }
 
    @RequestMapping(value = "rest")
    public String rest(@RequestBody ServiceInfo serviceInfo){
 
        return "Service1:Welcome " + serviceInfo.getName() + " !";
    }
}
